<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>党员登记系统</title>
    <link rel="stylesheet" href="css/bootstrap.css"/>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <style></style>
</head>

<body>
<nav class="nav navbar-inverse navbar-fixed-top" style="padding-left: 60px;" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a href="#" class="navbar-brand">
                <span class="glyphicon glyphicon-book"></span>
                <strong>党员登记系统</strong>
            </a>
        </div>
        <!--<div class="collapse nav-collapse">-->
        <div class="navbar-form pull-right">
            <div class="form-group">
                <!--<div class="input-group">-->
                <!--<div class="input-group-btn">-->
                <!--<input type="text" placeholder="请输入关键字" class="form-control" style="border-right: 0px;" />-->
                <!--</div>-->
                <!--<div class="input-group-btn">-->
                <!--<div class="btn btn-info"><span class="glyphicon glyphicon-search"></span></div>-->
                <!--</div>-->
                <!--</div>-->
            </div>
            <div class="form-group">
                <!--<span class="navbar-link" style="padding-left: 5px;">|</span>-->
                <!--<a href="#" class="navbar-link" style="padding-left: 5px;">帮助</a>-->
            </div>
        </div>
        <!--</div>-->
    </div>
</nav>
<div style="height: 50px;"></div>
<div class="container">
    <center>
        <h1 class="page-header">党员登记系统</h1>
    </center>
    <form class="form-horizontal">
        <div class="form-group">
            <div style="width:50%;margin-left: 25%;">
                <input id="uname" placeholder="请输入用户名" type="text" class="form-control"/>
            </div>
        </div>
        <div class="form-group">
            <div style="width:50%;margin-left: 25%;">
                <input id="pwd" placeholder="请输入密码" type="password" class="form-control"/>
            </div>
        </div>
        <!--<div class="col-md-9 col-md-offset-3">-->
            <!--<div class="form-group">-->
                <!--<input type="radio" name="usertype" value="admin" checked="true"> 管理员-->
                <!--<input type="radio" name="usertype" value="user"> 学院管理员-->
            <!--</div>-->
        <!--</div>-->
        <div class="form-group">
            <div style="width:50%;margin-left: 25%;">
                <div class="col-md-12 btn btn-circle btn-info" onclick="login()">
                    确认登录
                </div>
            </div>
        </div>

    </form>
</div>
</body>
<script type="text/javascript" src="js/common_var.js"></script>
<script type="text/javascript" src="./js/jquery.cookie.js"></script>
<script>
    $(function () {
        $(document).keydown(function (event) {
            if (event.keyCode == 13) {
                if ($('#usernumber').val() != "" && $('#password').val() != "") {
                    login();
                }
            }
        });
        if ($.cookie('type') &&$.cookie('department') &&$.cookie('id') ) {
            window.location.href = "index.html";
        }
    });

    function login() {
        var ajaxdata;
        ajaxdata = {
            uname: $('#uname').val(),
            pwd: $('#pwd').val(),
            type: 1
        };

        $.ajax({
            type: "get",
            url: "" + host + "Home/index/login",
            async: true,
            data: ajaxdata,
            datatype: "json",
            success: function (ret) {
                ret = eval('(' + ret + ')');
                if (ret['status'] == 1) {
                    $.cookie("id", ret['result']['id'], {
                        expires: 7
                    });
                    $.cookie("type", ret['result']['type'], {
                        expires: 7
                    });
                    $.cookie("department", ret['result']['department'], {
                        expires: 7
                    });
                    // $.cookie("TOKEN", ret['token'], {
                    //     expires: 7
                    // });
                    window.location.href = "index.html";
                } else {
                    alert(ret['msg']);
                }
            }
        });

    }
</script>

</html>